#include <iostream>
#include <vector>
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int t1 = -1, t2 = -1;
    for(int i = 0; i < n; i++){
        if(a[i] & 1) {
            if(t1 > a[i]) {
                cout << "NO\n";
                return;
            }
            t1 = a[i];
        }else{
            if(t2 > a[i]) {
                cout << "NO\n";
                return;
            }
            t2 = a[i];
        }
    }
    cout << "YES\n";
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}